Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: skip image download if it exists #447

Closed

Conversation

h0lyalg0rithm
Copy link
Contributor

@h0lyalg0rithm h0lyalg0rithm commented Aug 5, 2024

Proposed changes

There are multiple changes introduced in this PR

Download and Validate Image

flowchart TD
    A[downloadAndValidate] ---> B{Does the file file exist}
    B --->|Yes| C[Does the Checksum Match?]
    C ---> D[End]
    B --->|No| E[Download file]
    E ---> F[Match checksum]
    F ---> End
Loading
File Path: "Artifacts_PATH/file_name" - ARTIFACTS_PATH points to /tmp

HTTPClient Unification

Now an agent receives an instantiated client which makes all the http requests.Currently it configured to be not validate the server certificate.Injecting the httpclient allows us to test out the api client.

Types of changes

What types of changes does your code introduce to the repo? Put an x in the boxes that apply

  • New feature (non-breaking change which adds functionality)
  • Bugfix (non-breaking change which fixes an issue)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation Update (if none of the other choices applies)

Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.

  • I have signed the commit for DCO to be passed.
  • Lint and unit tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works (if appropriate)
  • I have added necessary documentation (if appropriate)

@h0lyalg0rithm h0lyalg0rithm requested a review from a team as a code owner August 5, 2024 17:44
Transport: &http.Transport{
TLSClientConfig: &tls.Config{
//nolint:gosec
InsecureSkipVerify: true, // TODO: remove skip verify

Check failure

Code scanning / CodeQL

Disabled TLS certificate check High

InsecureSkipVerify should not be used in production code.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@glimchb Should I remove this?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@h0lyalg0rithm we have a separate issue for this #341 if you remove it it will fail CI/CD.. need to fix server certs

sztp-agent/pkg/secureagent/daemon.go Fixed Show fixed Hide fixed
@h0lyalg0rithm h0lyalg0rithm force-pushed the cache_image_download branch 2 times, most recently from 2257429 to 95551e0 Compare August 5, 2024 17:51
if err != nil {
return err
}
func (a *Agent) downloadArtifact(uri string) (*os.File, error) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should download go to utils ?

@glimchb
Copy link
Member

glimchb commented Aug 5, 2024

@h0lyalg0rithm

  • refactor of HTTP client should be in a separate PR - too much changes to review at once
  • I think we missing a point from the issue: if same running image - no need to download regardless if file is present or not... for example you run ubuntu 22.09 already, why would you want to download it again, unless --force flag given or something like this... wdyt ?

@h0lyalg0rithm
Copy link
Contributor Author

  • ... for example you run ubuntu 22.09 already

Got it I assumed that if there are was an image present it would use it instead of downloading it.
I will move the httpclient change to a different PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants